cousin relationship

Terms from Artificial Intelligence: humans at the heart of algorithms

The meaning of 'cousin' varies between cultures, but within the AI book we adopt the definition that X is a cousin of Y if X is the offsping of a sibling of the parent of Y. For example the daughter of the brother of your mother is a cousin. In Prolog we might express this as:
      cousin{X,Y) :- child(X,A), sibling(A,B), child(Y,B).
Note that one has to be careful in translating these definitions into formal logics, as aspects that are 'obvious' the human may not be to a machine. For example, if (say in Prolog), we have parent child relationships, we might think that, "X is a sibling of Y" could be expressed as:
      sibling(A,B) :- child(A,P), child(B,P).
That is, a sibling of the child of your parent. However, this would mean that you are your own sibling (see code example tbirds.p), and hence when we put this into the cousin relationship, Prolog would conclude that your sister is a cousin or even that you are a cousin of yourself. We think "but of course when you say your sibling is a chld of your parent, you don't mean yourself!", but this has to be explicitly stated in a formal system.

Used on page 18